# import requests
#
#
# class TestReg:
#     def test_reg_success(self):
#         # 注册成功
#         session = requests.session()
#         session.get(
#             "http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.6326625486156849")
#         login_url = "http://tpshop-test.itheima.net/Home/User/reg.html"
#         header = {"Content-Type": "application/x-www-form-urlencoded"}
#         body = {"username": "13376589998", "verify_code": "8888", "password": "123456", "password2": "123456"}
#         resp = session.post(url=login_url, headers=header, data=body)
#         print(resp.json())
#
#         # 断言
#         assert 1 == resp.json().get('status')
#         assert '注册成功' == resp.json().get('msg')

# 这个和登录差不多的做法,定义class,这样为了时候pytest.
# 要先拿到验证码的url,在用错误账号获取注册接口的url(login_url),header和body的数据,用post方法,最后打印json格式文本,再断言即可
#
# import requests
# class TestLogin:
#     def testLogin_success(self):
#         session = requests.session()
#         session.get("http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.43388909248416674")
#         url = "http://tpshop-test.itheima.net/Home/User/reg.html"
#         header = {"Content-Type": "application/x-www-form-urlencoded"}
#         body = {"username":18874564382,"verify_code":8888,"password":123321,"password2":123321}
#         resp = session.post(url=url,headers=header,data=body)
#         print(resp.json())
#
#         assert 1 == resp.json().get('status')
#         assert '注册成功' == resp.json().get('msg')
#

# 使用参数化将列表list = [{"13800000002", "123456"}, {"13800001102","123456"},{"13800000002","124456"}]中的数据在ihrm登录接口上断言
# # @pytest.mark.parametrize
#参数化
import requests
import pytest
class TestLogin:
    list = [{"13800000002", "123456"}, {"13800001102", "123456"}, {"13800000002", "124456"}]
    @pytest.mark.parametrize("mobile,password", list)
    def test_login(self,mobile,password):
        url = 'http://ihrm-test.itheima.net/api/sys/login'
        header = {"Content-Type":"application/json"}
        body = {"mobile":mobile,"password":password}
        response = requests.post(url=url,headers=header,json=body)
        print(response.json())
        assert '操作成功！' == response.json().get('message') or '用户名或密码错误' == response.json()['message']


#

# import pytest
# import requests
#
# class Testlogin:
#     list = [{"13800000002", "123456"}, {"13800001102","123456"},{"13800000002","124456"}]
#     @pytest.mark.parametrize("mobile,password", list)
#     def testdata(self,mobile,password):
#         url = 'http://ihrm-test.itheima.net/api/sys/login'
#         header = {"Content-Type":"application/json"}
#         body = {"mobile":mobile,"password":password}
#         response = requests.post(url= url, headers=header,json=body)
#         print(response.json())
#         assert '操作成功！' == response.json()['message'] or '用户名或密码错误' == response.json()['message']
#


